package com.guigu.tms.oms.service.impl;

import com.guigu.tms.commons.order.entity.OrderCargo;
import com.guigu.tms.oms.mapper.OrderCargoMapper;
import com.guigu.tms.oms.service.IGoodsTypeService;
import com.guigu.tms.oms.service.IOrderCargoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 货品总重量  服务实现类
 * </p>
 *
 * @author zwj
 * @since 2022-09-27
 */
@Service
public class OrderCargoServiceImpl extends ServiceImpl<OrderCargoMapper, OrderCargo> implements IOrderCargoService {

    @Autowired
    private OrderCargoMapper orderCargoMapper;

    @Autowired
    private IGoodsTypeService goodsTypeService;

    @Override
    public boolean addOrderCargo(OrderCargo orderCargo) {
        return orderCargoMapper.insert(orderCargo)>0;
    }

    @Override
    public OrderCargo getOrderCargoByOrderId(String orderId) {
        OrderCargo orderCargo = orderCargoMapper.selectOrderCargoByOrderId(orderId);
        //根据货品类型编号查询货品类型
        orderCargo.setGoodsType(goodsTypeService.selectGoodsTypeById(orderCargo.getGoodsTypeId()));

        return orderCargo;
    }
}
